<!DOCTYPE html>
<html>

<head>

    {include file="Public:header"}
    <style>
        .radio-inline input[type=radio] {
            margin-top: 4px;
        }

        .note-editable {
            height: 150px
        }
    </style>
</head>

<body style="color:#333;padding:3px; overflow-x: auto;">
<!-- 标题 -->
<div class="page-heade">
    <h1 class="title_color">出库确认</h1>
</div>
<!-- 标题 -->
<div>
    <form action="" class="form-inline">
        <table class="row-margin-top tab-content table-bordered table" border="1" style="margin-bottom:0">
            <tr>
                <td style="min-width: 160px;width: 160px"><label for="">申请人：</label></td>
                <td><a href="javascript:;">{$data.sqrmc}</a></td>
                <td style="min-width: 160px;width: 160px"><label for="">申请人部门：</label></td>
                <td>{$data.sqrbm}</td>
                <td style="min-width: 160px;width: 160px"><label for="">申请日期：</label></td>
                <td>{$data.sqrq}</td>
            </tr>
            <tr>
                <td style="min-width: 160px;width: 160px"><label for="">确认人：</label></td>
                <td><a href="javascript:;">{$data.qrrmc}</a></td>
                <td style="min-width: 160px;width: 160px"><label for="">确认人部门：</label></td>
                <td>{$data.qrrbm}</td>
                <td style="min-width: 160px;width: 160px"><label for="">确认日期：</label></td>
                <td>{$data.qrrq}</td>
            </tr>
            <tr>
                <td style="min-width: 160px;width: 160px"><label for="">出库方式：</label></td>
                <td>{$data.ckfs}</td>
                <td style="min-width: 160px;width: 160px"><label for="">对应仓库<span class="colorRed">*</span>：</label>
                </td>
                <td>
                    <select name="dyck" id="" class="form-control">
                        <option value="">请选择</option>
                        {volist name="ck" id="row"}
                        <option value="{$row.id}" {if $data.dyck==$row.id}selected{/if}>{$row.ckjc}</option>
                        {/volist}
                    </select>
                </td>
                <td style="min-width: 160px;width: 160px"><label for="">对应销售订单：</label></td>
                <td><a href="{:url('wdxsdd',['id'=>$data.order_id])}">{$data.order_sn}</a></td>
            </tr>
            <tr>
                <td style="min-width: 160px;width: 160px">
                    <label for="" class="form-label">出库意见：</label>
                </td>
                <td colspan="5"><input type="text" class="form-control" name="ckyj" id=""></td>
            </tr>
            <tr>
                <td colspan="6" style="padding: 1px">
                    <table class="table table-bordered" style="margin:0;padding: 0">
                        <tr class="info">
                            <th class="text-center">序号</th>
                            <th class="text-center">类型</th>
                            <th class="text-center">编号</th>
                            <th class="text-center">名称</th>
                            <th class="text-center">单位</th>
                            <th class="text-center">申请数量</th>
                            {if $data.yck==1}
                            <th class="text-center">已出库数量</th>
                            {/if}
                            <th class="text-center">出库数量<span class="colorRed">*</span></th>
                            <th class="text-center">是否出库完毕</th>
                            <th class="text-center">体积(立方米)</th>
                            <th class="text-center">重量(吨)</th>
                        </tr>
                        {volist name="data.list" id="row" key="k"}
                        <tr data-dwtj="{$row.tj}" data-dwzl="{$row.zl}">
                            <td>{$k}</td>
                            <td>{if $data.wllx==1}销售物料{elseif $data.wllx==2}生产物料{else}成品{/if}</td>
                            <td>
                                {if $data.wllx==3}
                                <a href="{:url('TiApply/prodetail',['pid'=>$row.title])}" class="J_menuItem">{$row.pro_no}</a>
                                {else}
                                <a href="{:url('mtdetail',['pid'=>$row.title])}" class="J_menuItem">{$row.pro_no}</a>
                                {/if}
                            </td>
                            <td>{$row.title_name}</td>
                            <td>{$row.unit}</td>
                            <td class="text-right"><span class="ObjectNum">{$row.sqsl}</span>00</td>
                            {if $data.yck==1}
                            <td class="text-right"><span class="ObjectNum">{$row.sqsl-$row.num}</span>00</td>
                            {/if}
                            <td><input type="text" class="form-control" name="num[{$row.id}]" value="{$row.num}"></td>
                            <td><input type="checkbox" class="form-control" name="ckwb[{$row.id}]"></td>
                            <td class="text-right"><input type="hidden" name="tj[{$row.id}]"><span class="ObjectNum">{$row.tj*$row.num}</span>00</td>
                            <td class="text-right"><input type="hidden" name="zl[{$row.id}]"><span class="ObjectNum">{$row.zl*$row.num}</span>00000</td>
                        </tr>
                        {/volist}
                        <tr class="font-bold text-right">
                            <td colspan="5" class="text-right">小计：</td>
                            <td><span class="ObjectNum">{$data.sqsl_xj}</span>00</td>
                            {if $data.yck==1}
                            <td style="text-align: center;">{$data.ycksl_xj}</td>
                            {/if}
                            <td id="cksl_xj" style="text-align: center;">{$data.num_xj}</td>
                            <td></td>
                            <td><span class="ObjectNum">{$data.tj_xj}</span></td>
                            <td><span class="ObjectNum">{$data.zl_xj}</span></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td style="min-width: 160px;width: 160px">
                    <label for="" class="form-label">备注：</label>
                </td>
                <td colspan="5">{$data.bz}</td>
            </tr>
        </table>
        <div class="padding-10 text-center">
            <button class="btn btn-info" type="button" id="bfck">部分出库</button>
            <button class="btn btn-success" type="button" id="ckwb">出库完毕</button>
            <button class="btn btn-warning" type="button" id="fh" onclick="back()">返回</button>
        </div>
        <p class="padding-10">
            <label for="items">
                <span class="lr_5"></span><input type="checkbox" name="qrck" value="1" id="items"><span class="lr_5"></span><span
                    class="trTotal2 font-bold">剩余部分不再出库，设置本单为出库已完毕</span><span class="font-bold colorRed">（注意：如果选择剩余部分不再出库，则本单所有未出库部分都不再出库，同时本次操作也不做任何出库处理。）</span>
            </label>
        </p>
        <div id="qrck_box" style="display: none;">
            <table class="table table-bordered">
                <tr class="info">
                    <th>您将设置编号为'{$data.sn}'的出库申请单状态为出库已完毕。设置原因为<font color="red">*</font>:</th>
                </tr>
                <tr>
                    <td>
                        <input type="radio" name="sybckyy" value="1" checked>公司缺货，客户需重新下单
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="radio" name="sybckyy" value="2">其他原因: <input type="text" name="qtyy">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="radio" name="sybckyy" value="3">剩余订单金额太少，不能正常发货
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="radio" name="sybckyy" value="4">不能正常发货
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="radio" name="sybckyy" value="5">客户要求取消订单
                    </td>
                </tr>
                <tr>
                    <td class="text-center">
                        <button class="btn btn-info" type="button" id="szwckywb">设置为出库已完毕</button>
                        <button class="btn btn-success" type="button" id="qxsz">取消设置</button>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</div>


</body>
{include file="Public:footer"}
<script src="__STATIC__/layout/js/contabs_sub.js"></script>
<script src="__STATIC__/layout/js/common.js"></script>
<script>
    $(document).ready(function () {
        //取消设置
        $('#qxsz').on('click',function () {
            $('#qrck_box').hide()
            $('#items').prop('checked',false)
            $('#bfck,#ckwb,#fh').prop('disabled',false)
        })
        //剩余部分不再出库
        $('#items').on('click',function () {
            if($(this).prop('checked')){
                $('#qrck_box').show()
                $('#bfck,#ckwb,#fh').prop('disabled',true)
            }else{
                $('#qrck_box').hide()
                $('#bfck,#ckwb,#fh').prop('disabled',false)
            }
        })
        /**
         * 部分出库
         */
        $('#bfck').on('click',function () {
            var param = $(this).closest('form').serialize()
            param += '&bfck=1'
            $.post('',param,function (data) {
                if(data.success){
                    swal({title:data.msg},function () {
                        location.href='{:url("ckgl")}'
                    })
                }else{
                    swal('',data.msg,'error')
                }
            },'json')
            return false
        })
        /**
         * 设置为出库已完毕
         */
        $('#szwckywb').on('click',function () {
            var param = $(this).closest('form').serialize()
            param += '&bfck=1&qrck=1'
            $.post('',param,function (data) {
                if(data.success){
                    swal({title:data.msg},function () {
                        location.href='{:url("ckgl")}'
                    })
                }else{
                    swal('',data.msg,'error')
                }
            },'json')
            return false
        })
        /**
         * 出库完毕
         */
        $('#ckwb').on('click',function () {
            var param = {}
            param.dyck = $('[name=dyck]').val()
            param.ckyj = $('[name=ckyj]').val()
            param.bfck = 2
            $.post('',param,function (data) {
                if(data.success){
                    swal({title:data.msg},function () {
                        location.href='{:url("ckgl")}'
                    })
                }else{
                    swal('',data.msg,'error')
                }
            },'json')
            return false
        })

        //输入数量
        $('input[name^=num]').on('input',function () {
            var hj = 0;
            $('[name^=num]').each(function (i,o) {
                hj += parseInt($(o).val()?$(o).val():0)
            })
            $('#cksl_xj').html(hj)
            //计算体积
            //获取单位体积和重量
            var dwtj = $(this).closest('tr').data('dwtj')
            var dwzl = $(this).closest('tr').data('dwzl')
            var num = $(this).val()?$(this).val():0
            var tj = parseFloat(num)*parseFloat(dwtj?dwtj:0)
            var zl = parseFloat(num)*parseFloat(dwzl?dwzl:0)
            $(this).closest('tr').find('[name^=tj]').val(tj)
            $(this).closest('tr').find('[name^=tj]').next('span').html(tj)
            $(this).closest('tr').find('[name^=zl]').val(zl)
            $(this).closest('tr').find('[name^=zl]').next('span').html(zl)
        })
        var $ObjectNum = $(".ObjectNum");
        toNum($ObjectNum);
    })
</script>
</html>
